<template>
	<view>
		<view class="defalutebg" @click="addpic">
			<image :src="screenshot" mode="aspectFill"></image>
		</view>
		<view class="desc" >
			<view>请提交您的应用商店五星好评截图，系统识别成功后即可领取金币奖励。我要<text @click="gotopl" class="pl">去评论截图</text></view>
		</view>
		<view class="button" @click="comfir">立即提交</view>
	</view>
</template>

<script>
	/**
	 * 评分数据
	 */
	//const storeKit = uni.requireNativePlugin('Xty-StoreKit');
	export default {
		data() {
			return {
				screenshot: ''
			}
		},
		methods: {
			//去评论
			gotopl(){
				// 
				let url =''
				if(plus.os.name=='iOS') {
					url = "https://apps.apple.com/cn/app/%E5%A4%A9%E5%A4%A9%E6%9C%89%E7%A4%BC/id1527976390"
				}else{
					url="https://android.myapp.com/myapp/detail.htm?apkName=co.m607068.recharge"
				}
				plus.runtime.openURL(url) 
			},
			//提交截图
			comfir() {
				let _this=this
				if (!this.screenshot) {
					this.$ShowMsg('请上传评分截图', 'error')
					return
				}
				uni.showLoading({
					title: '图片识别中...',
					mask: true
				})
				setTimeout(()=>{
					_this.$HttRequest({
						url: '/task/fiveStarPraise',
						param: '',
					}).then(res => {
						console.log(res)
						if (res.status === 10000) {
							_this.$ShowMsg('评分图上传成功，返回后下拉刷新页面领取！')
							setTimeout(()=>{
								uni.navigateBack({
									delta:1
								})
							},2500)
						} else {
							_this.$ShowMsg(res.message,'error')
						}
					}).catch(error => {
						_this.$ShowMsg('error::'+error)
					})
				},2000)
			},
			addpic() {
				let _this = this
				uni.chooseImage({
					count: 1, //默认8
					sizeType: ['compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(ImageRes) {
						//console.log(ImageRes)
						_this.screenshot = ImageRes.tempFilePaths[0]
					},
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f0f0f0;
	}

	.desc {
		width: 90%;
		margin: 20rpx auto;
		margin-top: 0;
		font-size: 28rpx;
		color: #9e9e9e;
		display: flex;
		justify-content:  center;
		align-items: flex-start;
		
		.pl{
			color: $uni-color-primary;
		}
	}

	.defalutebg {
		background-image: url(../../static/image/screenshot.png);
		background-size: 400rpx 600rpx;
		width: 400rpx;
		height: 680rpx;
		margin: 50rpx auto;
		background-repeat: no-repeat;
		background-position: left bottom;
		image {
			width: 400rpx;
			height: 680rpx;
		}
	}

	.button {
		background-color: $uni-color-primary;
		width: 80%;
		height: 85rpx;
		margin: 30rpx auto;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		border-radius: 40rpx;
		margin-top: 80rpx;
		font-size: 32rpx;
	}
</style>
